﻿using System;
using System.Collections.Generic;

using breakoutsharp.visual.gameobject;

namespace breakoutsharp.core
{
    public sealed class Level : IDisposable
    {
        public List<IBlock> Blocks { get; private set; }
        public List<Ball> Balls { get; private set; }
        public List<Booster> AvailableBoosters { get; private set; }
        private bool disposedValue;

        public Level(List<IBlock> blocks)
        {
            this.Blocks = blocks;

            if (this.Balls == null)
                Balls = new List<Ball>();

            if (this.AvailableBoosters == null)
                AvailableBoosters = new List<Booster>();
        }

        public Level(List<IBlock> blocks, List<Ball> balls) : this(blocks)
        {
            this.Balls = balls;
        }

        public Level(List<IBlock> blocks, List<Ball> balls, List<Booster> boosters) : this(blocks, balls)
        {
            this.AvailableBoosters = boosters;
        }

        // IDisposable
        private void Dispose(bool disposing)
        {
            if (!this.disposedValue)
            {
                if (disposing)
                {
                    // TODO: free other state (managed objects).

                    if (Blocks != null)
                        Blocks.Clear();
                    if (Balls != null)
                        Balls.Clear();
                    if (AvailableBoosters != null)
                        AvailableBoosters.Clear();
                }

            }

            // TODO: free your own state (unmanaged objects).
            // TODO: set large fields to null.
            this.disposedValue = true;
        }

        // This code added by Visual Basic to correctly implement the disposable pattern.
        public void Dispose()
        {
            // Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}
